package org.timeticker;

import java.util.List;

/**
 * Persistance interface.
 *
 * @author Ivan Latysh
 * @version 0.1
 * @since 16-Jul-2007 : 9:19:24 PM
 */
public interface Persistence {

  /**
   * Persist given object list
   *
   * @param key object list key
   * @param list object list
   * @throws IllegalArgumentException when activity list or date is null
   * @throws Exception when unable to save activity list
   */
  public void persistObjectList(String key, ObjectList list) throws IllegalArgumentException, Exception;

  /**
   * Restore object list with given key
   *
   * @param key object list key
   * @return object list or <tt>null</tt> when no object list with given key exists
   * @throws IllegalArgumentException when activity list or date is null
   * @throws Exception when unable to save activity list
   * @see #isObjectListExists(String) 
   */
  public ObjectList restoreObjectList(String key) throws IllegalArgumentException, Exception;

  /**
   * Check if object list with given key exists
   *
   * @param key object list key
   * @return <tt>true</tt> when object list exist, <tt>false</tt> otherwise
   */
  public boolean isObjectListExists(String key);

  /**
   * Return list of the key matching given pattern
   *
   * @param pattern an regex pattern
   * @return list keys
   * @see java.util.regex.Pattern
   */
  public List<String> getKeyList(String pattern);

}
